

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/xt-blog/img/favicon.png">
  <link rel="icon" href="/xt-blog/img/favicon.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="xue tao">
  <meta name="keywords" content="">
  
    <meta name="description" content="难度：中等             题目给你一个有 n 个服务器的计算机网络，服务器编号为 0 到 n - 1 。同时给你一个二维整数数组 edges ，其中 edges[i] &#x3D; [ui, vi] 表示服务器 ui 和 vi 之间有一条信息线路，在 一秒 内它们之间可以传输 任意 数目的信息。再给你一个长度为 n 且下标从 0 开始的整数数组 patience 。 题目">
<meta property="og:type" content="article">
<meta property="og:title" content="2039_网络空闲的时刻">
<meta property="og:url" content="https://accept_one_time.gitee.io/xt-blog/2022/03/20/2039-%E7%BD%91%E7%BB%9C%E7%A9%BA%E9%97%B2%E7%9A%84%E6%97%B6%E5%88%BB/index.html">
<meta property="og:site_name" content="学涛的博客">
<meta property="og:description" content="难度：中等             题目给你一个有 n 个服务器的计算机网络，服务器编号为 0 到 n - 1 。同时给你一个二维整数数组 edges ，其中 edges[i] &#x3D; [ui, vi] 表示服务器 ui 和 vi 之间有一条信息线路，在 一秒 内它们之间可以传输 任意 数目的信息。再给你一个长度为 n 且下标从 0 开始的整数数组 patience 。 题目">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/accept_one_time/pic-bed/raw/master/img/20220320113444.png">
<meta property="og:image" content="https://gitee.com/accept_one_time/pic-bed/raw/master/img/20220320113408.png">
<meta property="article:published_time" content="2022-03-20T03:29:33.000Z">
<meta property="article:modified_time" content="2022-03-20T03:59:36.849Z">
<meta property="article:author" content="xue tao">
<meta property="article:tag" content="leetcode">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://gitee.com/accept_one_time/pic-bed/raw/master/img/20220320113444.png">
  
  
  <title>2039_网络空闲的时刻 - 学涛的博客</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4/github-markdown.min.css" />
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hint.css@2/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css" />
  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/xt-blog/css/main.css" />

<!-- 自定义样式保持在最底部 -->

  
<link rel="stylesheet" href="/xt-blog/css/mac.css">



  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"accept_one_time.gitee.io","root":"/xt-blog/","version":"1.8.14","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/xt-blog/local-search.xml"};
  </script>
  <script  src="/xt-blog/js/utils.js" ></script>
  <script  src="/xt-blog/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.4.1"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/xt-blog/">
      <strong>学涛的博客</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/xt-blog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/xt-blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                文档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/xt-blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/xt-blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/xt-blog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/xt-blog/img/default.jpg') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="2039_网络空闲的时刻">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2022-03-20 11:29" pubdate>
        2022年3月20日 上午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      3.5k 字
    </span>
  

  
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      30 分钟
    </span>
  

  
  
</div>

            
          </div>

          
            <div class="scroll-down-bar">
              <i class="iconfont icon-arrowdown"></i>
            </div>
          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">2039_网络空闲的时刻</h1>
            
            <div class="markdown-body">
              <div class="note note-warning">
            <p>难度：中等</p>
          </div>

<h2 id="题目"><a href="#题目" class="headerlink" title="题目"></a>题目</h2><p>给你一个有 n 个服务器的计算机网络，服务器编号为 0 到 n - 1 。同时给你一个二维整数数组 edges ，其中 edges[i] = [ui, vi] 表示服务器 ui 和 vi 之间有一条信息线路，在 <strong>一秒</strong> 内它们之间可以传输 任意 数目的信息。再给你一个长度为 n 且下标从 0 开始的整数数组 patience 。</p>
<p>题目保证所有服务器都是 相通 的，也就是说一个信息从任意服务器出发，都可以通过这些信息线路直接或间接地到达任何其他服务器。</p>
<p>编号为 <strong>0</strong> 的服务器是 <strong>主</strong> 服务器，其他服务器为 <strong>数据</strong> 服务器。每个数据服务器都要向主服务器发送信息，并等待回复。信息在服务器之间按 <strong>最优</strong> 线路传输，也就是说每个信息都会以 <strong>最少时间</strong> 到达主服务器。主服务器会处理 <strong>所有</strong> 新到达的信息并 立即 按照每条信息来时的路线 <strong>反方向</strong> 发送回复信息。</p>
<p>在 0 秒的开始，所有数据服务器都会发送各自需要处理的信息。从第 1 秒开始，<strong>每</strong> 一秒最 开始 时，每个数据服务器都会检查它是否收到了主服务器的回复信息（包括新发出信息的回复信息）：</p>
<p>如果还没收到任何回复信息，那么该服务器会周期性 <strong>重发</strong> 信息。数据服务器 i 每 patience[i] 秒都会重发一条信息，也就是说，数据服务器 i 在上一次发送信息给主服务器后的 patience[i] 秒 后 会重发一条信息给主服务器。<br>否则，该数据服务器 不会重发 信息。<br><strong>当没有任何信息在线路上传输或者到达某服务器时，该计算机网络变为 空闲 状态。</strong></p>
<p>请返回计算机网络变为 <strong>空闲</strong> 状态的 <strong>最早秒数</strong> 。</p>
<h2 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h2><p>示例一：</p>
<p><img src="https://gitee.com/accept_one_time/pic-bed/raw/master/img/20220320113444.png" srcset="/xt-blog/img/loading.gif" lazyload alt="example 1"></p>
<blockquote>
<p><strong>输入</strong>：edges = [[0,1],[1,2]], patience = [0,2,1]<br><strong>输出</strong>：8<br><strong>解释</strong>：<br>0 秒最开始时，</p>
<ul>
<li>数据服务器 1 给主服务器发出信息（用 1A 表示）。</li>
<li>数据服务器 2 给主服务器发出信息（用 2A 表示）。</li>
</ul>
<p>1 秒时，</p>
<ul>
<li>信息 1A 到达主服务器，主服务器立刻处理信息 1A 并发出 1A 的回复信息。</li>
<li>数据服务器 1 还没收到任何回复。距离上次发出信息过去了 1 秒（1 &lt; patience[1] = 2），所以不会重发信息。</li>
<li>数据服务器 2 还没收到任何回复。距离上次发出信息过去了 1 秒（1 == patience[2] = 1），所以它重发一条信息（用 2B 表示）。</li>
</ul>
<p>2 秒时，</p>
<ul>
<li>回复信息 1A 到达服务器 1 ，服务器 1 不会再重发信息。</li>
<li>信息 2A 到达主服务器，主服务器立刻处理信息 2A 并发出 2A 的回复信息。</li>
<li>服务器 2 重发一条信息（用 2C 表示）。<br>…<br>4 秒时，</li>
<li>回复信息 2A 到达服务器 2 ，服务器 2 不会再重发信息。<br>…<br>7 秒时，回复信息 2D 到达服务器 2 。</li>
</ul>
<p>从第 8 秒开始，不再有任何信息在服务器之间传输，也不再有信息到达服务器。<br>所以第 8 秒是网络变空闲的最早时刻。</p>
</blockquote>
<p>示例二：</p>
<p><img src="https://gitee.com/accept_one_time/pic-bed/raw/master/img/20220320113408.png" srcset="/xt-blog/img/loading.gif" lazyload alt="example 2"></p>
<blockquote>
<p><strong>输入</strong>：edges = [[0,1],[0,2],[1,2]], patience = [0,10,10]<br><strong>输出</strong>：3<br><strong>解释</strong>：数据服务器 1 和 2 第 2 秒初收到回复信息。<br>从第 3 秒开始，网络变空闲。</p>
</blockquote>
<h2 id="提示"><a href="#提示" class="headerlink" title="提示"></a>提示</h2><ul>
<li>n == patience.length</li>
<li>2 &lt;= n &lt;= 105</li>
<li>patience[0] == 0</li>
<li>对于 1 &lt;= i &lt; n ，满足 1 &lt;= patience[i] &lt;= 105</li>
<li>1 &lt;= edges.length &lt;= min(105, n * (n - 1) / 2)</li>
<li>edges[i].length == 2</li>
<li>0 &lt;= ui, vi &lt; n</li>
<li>ui != vi</li>
<li>不会有重边。</li>
<li>每个服务器都直接或间接与别的服务器相连。</li>
</ul>
<h2 id="解题"><a href="#解题" class="headerlink" title="解题"></a>解题</h2><p>选择最短距离到达主服务器，可以考虑广度优点算法，网络的最早空闲时间为各个节点中最晚的空闲时间</p>
<p>先用 List 数组存储无向图，同时用一个 boolean 数组记录访问状态，防止重复访问</p>
<figure class="highlight java"><table><tr><td class="gutter"><div class="code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></div></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">int</span> n = patience.length;<br>List&lt;Integer&gt;[] adj = <span class="hljs-keyword">new</span> List[n];<br><span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; n; i++) &#123;<br>  adj[i] = <span class="hljs-keyword">new</span> ArrayList&lt;&gt;();<br>&#125;<br><span class="hljs-keyword">boolean</span>[] visited = <span class="hljs-keyword">new</span> <span class="hljs-keyword">boolean</span>[n];<br><span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span>[] edge:edges)&#123;<br>  adj[edge[<span class="hljs-number">0</span>]].add(edge[<span class="hljs-number">1</span>]);<br>  adj[edge[<span class="hljs-number">1</span>]].add(edge[<span class="hljs-number">0</span>]);<br>&#125;<br></code></pre></td></tr></table></figure>

<p>执行广度优先算法</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><code class="hljs java">Queue&lt;Integer&gt; queue = <span class="hljs-keyword">new</span> ArrayDeque&lt;&gt;();<br>queue.offer(<span class="hljs-number">0</span>);<br>visited[<span class="hljs-number">0</span>] = <span class="hljs-keyword">true</span>;<br><span class="hljs-keyword">int</span> dist = <span class="hljs-number">1</span>;<br><span class="hljs-keyword">int</span> ans = <span class="hljs-number">0</span>;<br><span class="hljs-keyword">while</span> (!queue.isEmpty())&#123;<br>  <span class="hljs-keyword">int</span> size = queue.size();<br>  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; size; i++) &#123;<br>    <span class="hljs-keyword">int</span> curr = queue.poll();<br>    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> v:adj[curr])&#123;<br>      <span class="hljs-comment">// 遍历每个节点的可达节点</span><br>      <span class="hljs-keyword">if</span> (visited[v])&#123;<br>        <span class="hljs-keyword">continue</span>;<br>      &#125;<br>      queue.offer(v);<br>    &#125;<br>  &#125;<br>  dist++;<br>&#125;<br></code></pre></td></tr></table></figure>

<ul>
<li>当每个节点和主服务器的距离 dist 符合 $2 * dist &lt;= patience[i]$ 时，此节点还未发送第二条消息就收到了回复，所以空闲时间为 $2 * dist + 1$</li>
<li>当节点与主服务器的距离符合 $2*dist&gt;patience[i]$ 时，还未收到第一条消息的回复就要发送第二条消息，在收到第一条回复前会发送 $\lfloor \frac{2\times dist -1}{patience[i]} \rfloor$ 次消息，最后一次发送消息的时间为 $patience[v]\times\lfloor \frac{2\times dist -1}{patience[v]} \rfloor$ ，节点每次发送消息会经过 $2 \times dist$ 的时间收到回复，所以节点最后一次收到回复的时间为 $patience[v]\times\lfloor \frac{2\times dist -1}{patience[v]} \rfloor + 2 \times dist$ ，所以空闲时间为 $patience[v]\times\lfloor \frac{2\times dist -1}{patience[v]} \rfloor + 2 \times dist + 1$ </li>
</ul>
<p>可以对结果进行合并，当 $2\times dist \le patience[i]$ 时，$\lfloor \frac{2\times dist -1}{patience[i]} \rfloor$ 刚好为 0 ，所以变为空闲的时间为 $patience[v]\times\lfloor \frac{2\times dist -1}{patience[v]} \rfloor + 2 \times dist + 1$</p>
<p>最终解答如下：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">int</span> <span class="hljs-title">networkBecomesIdle</span><span class="hljs-params">(<span class="hljs-keyword">int</span>[][] edges, <span class="hljs-keyword">int</span>[] patience)</span></span>&#123;<br>  <span class="hljs-keyword">int</span> n = patience.length;<br>  List&lt;Integer&gt;[] adj = <span class="hljs-keyword">new</span> List[n];<br>  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; n; i++) &#123;<br>    adj[i] = <span class="hljs-keyword">new</span> ArrayList&lt;&gt;();<br>  &#125;<br>  <span class="hljs-keyword">boolean</span>[] visited = <span class="hljs-keyword">new</span> <span class="hljs-keyword">boolean</span>[n];<br>  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span>[] edge:edges)&#123;<br>    adj[edge[<span class="hljs-number">0</span>]].add(edge[<span class="hljs-number">1</span>]);<br>    adj[edge[<span class="hljs-number">1</span>]].add(edge[<span class="hljs-number">0</span>]);<br>  &#125;<br>  Queue&lt;Integer&gt; queue = <span class="hljs-keyword">new</span> ArrayDeque&lt;&gt;();<br>  queue.offer(<span class="hljs-number">0</span>);<br>  visited[<span class="hljs-number">0</span>] = <span class="hljs-keyword">true</span>;<br>  <span class="hljs-keyword">int</span> dist = <span class="hljs-number">1</span>;<br>  <span class="hljs-keyword">int</span> ans = <span class="hljs-number">0</span>;<br>  <span class="hljs-keyword">while</span> (!queue.isEmpty())&#123;<br>    <span class="hljs-keyword">int</span> size = queue.size();<br>    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; size; i++) &#123;<br>      <span class="hljs-keyword">int</span> curr = queue.poll();<br>      <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> v:adj[curr])&#123;<br>        <span class="hljs-keyword">if</span> (visited[v])&#123;<br>          <span class="hljs-keyword">continue</span>;<br>        &#125;<br>        queue.offer(v);<br>        <span class="hljs-comment">// 合并后的结果</span><br>        <span class="hljs-keyword">int</span> time = patience[v]*((<span class="hljs-number">2</span>*dist-<span class="hljs-number">1</span>)/patience[v])+<span class="hljs-number">2</span>*dist+<span class="hljs-number">1</span>;<br>        <span class="hljs-comment">// 取最大值返回</span><br>        ans = Math.max(ans,time);<br>        <span class="hljs-comment">// 更新访问状态</span><br>        visited[v] = <span class="hljs-keyword">true</span>;<br>      &#125;<br>    &#125;<br>    <span class="hljs-comment">// 更新当前距离</span><br>    dist++;<br>  &#125;<br>  <span class="hljs-keyword">return</span> ans;<br>&#125;<br></code></pre></td></tr></table></figure>


            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/xt-blog/categories/Leetcode/">Leetcode</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/xt-blog/tags/leetcode/">leetcode</a>
                    
                  </div>
                
              </div>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/xt-blog/2022/03/22/8-%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%BD%AC%E6%8D%A2%E6%95%B4%E6%95%B0%EF%BC%88atoi%EF%BC%89/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">8_字符串转换整数（atoi）</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/xt-blog/2022/03/19/1028-%E4%BB%8E%E5%85%88%E5%BA%8F%E9%81%8D%E5%8E%86%E8%BF%98%E5%8E%9F%E4%BA%8C%E5%8F%89%E6%A0%91/">
                        <span class="hidden-mobile">1028_从先序遍历还原二叉树</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     Peace <i class="iconfont icon-love"></i> Love 
  </div>
  

  

  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/js/bootstrap.min.js" ></script>
<script  src="/xt-blog/js/events.js" ></script>
<script  src="/xt-blog/js/plugins.js" ></script>

<!-- Plugins -->


  <script  src="/xt-blog/js/local-search.js" ></script>



  
    <script  src="/xt-blog/js/img-lazyload.js" ></script>
  



  



  
    <script  src="https://cdn.jsdelivr.net/npm/tocbot@4/dist/tocbot.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4/anchor.min.js" ></script>
  
  
    <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js" ></script>
  






  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
        typing(title);
      
    })(window, document);
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/xt-blog/js/boot.js" ></script>


</body>
</html>
